home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / disp182a.zip / DRVSRC / ATIULTRA.ASM < prev    next >
Assembly Source File  |  1994-02-23  |  13KB  |  453 lines

  1. ;--------------------------------------------------------------------------
  2. ; This is file ATIULTRA.ASM
  3. ;
  4. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  5. ; Copyright (C) 1992 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
  6. ;
  7. ; This file is distributed under the terms listed in the document
  8. ; "copying.dj", available from DJ Delorie at the address above.
  9. ; A copy of "copying.dj" should accompany this file; if not, a copy
  10. ; should be available from where this file was obtained.  This file
  11. ; may not be distributed without a verbatim copy of "copying.dj".
  12. ;
  13. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  14. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. ;--------------------------------------------------------------------------
  16.  
  17. _TEXT    segment byte public 'CODE'
  18. _TEXT    ends
  19. DGROUP  group    _TEXT,_DATA,_BSS
  20.     assume  cs:_TEXT,ds:DGROUP
  21. _DATA    segment word public 'DATA'
  22. d@    label    byte
  23. d@w    label    word
  24. _DATA    ends
  25. _BSS    segment word public 'BSS'
  26. b@    label    byte
  27. b@w    label    word
  28. _BSS    ends
  29. _TEXT    segment byte public 'CODE'
  30.     assume  cs:_TEXT,ds:DGROUP
  31.  
  32. include grdriver.inc
  33.  
  34. ;--------------------------------------------------------------------------
  35. ; DRIVER HEADER
  36. ;  The following entries MUST match the structure and constant
  37. ;  declarations in the file 'grdriver.h' of the GRX graphics library
  38. ;  The mode word should contain the following bitfields:
  39. ;     - the GRD_NEW_DRIVER bit set for any new format driver
  40. ;     - the adapter type field should be specified
  41. ;     - the memory size field should be specified
  42. ;     - the paging mode field should be specified
  43. ;  The mode set routine will OR in the plane bitfield as it will
  44. ;  change when different color number modes are requested.
  45. ;--------------------------------------------------------------------------
  46.  
  47.     dw    offset mode_set_routine
  48.     dw    offset paging_routine
  49. mode_W  dw    GRD_NEW_DRIVER+GRD_VGA+GRD_256K+GRD_RW_64K
  50. ;
  51. ; The 'def_xx' fields are filled in by go32 from the corresponding
  52. ; fields of the 'GO32' environment variable
  53. ;
  54. def_tw  dw    80        ; text width
  55. def_th  dw    25        ; text height
  56. def_gw  dw    640        ; graphics width
  57. def_gh  dw    480        ; graphics height
  58. def_nc  dw    16        ; graphics colors
  59.     dw    offset driver_init_routine
  60.     dw    offset text_mode_table
  61.     dw    offset graphics_mode_table
  62.  
  63. ;
  64. ; Biggest text and graphics sizes
  65. ;
  66. Max_TW  equ    132
  67. Max_TH  equ    44
  68. Max_GWn equ    800        ; non interlaced!!!
  69. Max_GHn equ    600
  70. Max_GW  equ    1024        ; may be interlaced
  71. Max_GH  equ    768
  72.  
  73.  
  74. ;--------------------------------------------------------------------------
  75. ; TABLE OF SUPPORTED TEXT MODES
  76. ;    - keep sorted by size
  77. ;    - end with an all 0 entry
  78. ;    - BIOS field = 0xff disables it
  79. ;    - fields:
  80. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  81. ;--------------------------------------------------------------------------
  82. text_mode_table        label word
  83.     dw    80,    25,    2,    007h +  00000h
  84.     dw    40,    25,    16,    001h +  00000h
  85.     dw    80,    25,    16,    003h +  00000h
  86.     dw    80,    28,    16,    003h +  00400h
  87.     dw    80,    50,    16,    003h +  00100h
  88.     dw    132,    25,    16,    023h +  00000h
  89.     dw    132,    28,    16,    023h +  00400h
  90.     dw    132,    44,    16,    033h +  00000h
  91.     dw    132,    50,    16,    023h +  00100h
  92.     dw    0,    0,    0,    000h +  00000h
  93.  
  94. ;--------------------------------------------------------------------------
  95. ; TABLE OF SUPPORTED GRAPHICS MODES
  96. ;    - keep sorted first by colors then by size
  97. ;    - end with an all 0 entry
  98. ;    - BIOS field = 0xff disables it
  99. ;    - fields:
  100. ;        width,  height, colors, BIOS#+  setup_procedure_index*256
  101. ;--------------------------------------------------------------------------
  102. graphics_mode_table    label word
  103.     dw    320,    200,    16,    00dh +  00000h
  104.     dw    640,    200,    16,    00eh +  00000h
  105.     dw    640,    350,    16,    010h +  00000h
  106.     dw    640,    480,    16,    012h +  00000h
  107.     dw    800,    600,    16,    054h +  00000h
  108.     dw    1024,    768,    16,    055h +  00000h
  109.     dw    320,    200,    256,    013h +  00000h
  110.     dw    640,    400,    256,    061h +  00000h
  111. begin_8514_modes    label word
  112.     dw    640,    480,    256,    000h +  00300h     ; use 8514 mode
  113.     dw    1024,    768,    256,    001h +  00300h     ; use 8514 mode
  114.     dw    0,    0,    0,    000h +  00000h
  115.  
  116. ;--------------------------------------------------------------------------
  117. ; TABLE OF SPECIAL SETUP PROCEDURES
  118. ;  You may need such procedures for:
  119. ;     -- reloading fonts on standard EGA or VGA for
  120. ;     higher resolution text modes
  121. ;     -- enable HiColor mode of some Super VGAs
  122. ;     -- Handle the parameter passing conventions of the VESA BIOS
  123. ;     -- put VGA into 256 color plane mode ("MODE X")
  124. ;     -- etc...
  125. ;  There should be one entry in the table for every non-zero
  126. ;  'setup_procedure_index' in the text and graphics mode tables.
  127. ;  The first entry in the table belongs to index 100h, and so on.
  128. ;  The special setup procedure is invoked via a near call.
  129. ;
  130. ;  Entry: DI=address of the mode record from the text or graphics
  131. ;      table to set up.
  132. ;
  133. ;  Exit:  Adapter configured
  134. ;      BX=driver mode word as it should be returned by the mode set
  135. ;         routine. Typically it involves picking up the mode word
  136. ;         from the header and OR-ing in the appropriate bitplane mode
  137. ;         bitfield. (This is not needed for text modes)
  138. ;      AX, CX, DX, SI can be trashed, PRESERVE DI!!!!
  139. ;
  140. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  141. ;--------------------------------------------------------------------------
  142. special_setup_table    label word
  143.     dw    offset  VGA_50row_mode_set
  144.     dw    offset  VGA_MODE_X_set
  145.     dw    offset  IBM_8514_mode_set
  146.     dw    offset  VGA_28row_mode_set
  147.  
  148. ;
  149. ; Routine to set up VGA 50 row mode
  150. ; interface is described above
  151. ;
  152. VGA_50row_mode_set    proc    near
  153.     call    near ptr disable_8514A
  154.     mov    ax,WORD PTR [di+6]    ; get base mode number
  155.     xor    ah,ah
  156.     int    10h
  157.     xor    bx,bx
  158.     mov    ax,1112h        ; load 8x8 font
  159.     int    10h
  160.     ret
  161. VGA_50row_mode_set    endp
  162.  
  163. ;
  164. ; Routine to set up VGA 28 row mode
  165. ; interface is described above
  166. ;
  167. VGA_28row_mode_set    proc    near
  168.     call    near ptr disable_8514A
  169.     mov    ax,WORD PTR [di+6]    ; get base mode number
  170.     xor    ah,ah
  171.     int    10h
  172.     xor    bx,bx
  173.     mov    ax,1111h        ; load 8x14 font
  174.     int    10h
  175.     ret
  176. VGA_28row_mode_set    endp
  177.  
  178. ;
  179. ; Routine to set up VGA 256 color plane mode ("MODE X")
  180. ; interface is described above
  181. ; TO BE COMPLETED
  182. ;
  183. VGA_MODE_X_set        proc    near
  184.     mov    bx,mode_W
  185.     or    bx,GRD_8_X_PLANES
  186.     ret
  187. VGA_MODE_X_set        endp
  188.  
  189. ;
  190. ; Routine to set up 8514A 256 color mode
  191. ; interface is described above
  192. ;
  193. IBM_8514_mode_set    proc    near
  194.     mov    al,BYTE PTR [di+6]
  195.     xor    ah,ah
  196.     push    ax
  197.     call    near ptr setup_8514A_256_color_mode
  198.     pop    ax
  199.     mov    bx,GRD_NEW_DRIVER+GRD_8514A+GRD_8_PLANES
  200.     ret
  201. IBM_8514_mode_set    endp
  202.  
  203.  
  204. ;--------------------------------------------------------------------------
  205. ; DRIVER INIT ROUTINE
  206. ;  called once after the driver is loaded
  207. ;  may do one or more of the followings:
  208. ;    - check for proper board type
  209. ;    - check amount of RAM on board, and:
  210. ;    -- update word in header to reflect correct amount
  211. ;    -- disable modes in the tables for which there is not enough RAM
  212. ;    - check for special equipment (HiColor DAC, etc...)
  213. ;
  214. ;  Entry: nothing
  215. ;
  216. ;  Exit:  AX=status:
  217. ;       non-zero: OK,
  218. ;       0: something went wrong (e.g. wrong adapter, etc..)
  219. ;      BX,CX,DX may be trashed
  220. ;
  221. ;  NOTE: This runs in real mode, but don't mess with the segment registers.
  222. ;--------------------------------------------------------------------------
  223. driver_init_routine    proc    far
  224.     push    ds
  225.     mov    ax,cs
  226.     mov    ds,ax
  227.     call    near ptr check_8514A    ; test for 8514A
  228.     or    ax,ax
  229.     jne    have_8514A
  230.     mov    bx,offset begin_8514_modes
  231.     mov    WORD PTR [bx+6],062h    ; use SVGA mode for 640x480x256
  232.     mov    WORD PTR [bx+14],0ffh    ; invalidate 1024x768x256
  233. have_8514A:
  234.     mov    ax,1
  235.     pop    ds
  236.     ret
  237. driver_init_routine    endp
  238.  
  239.  
  240. ;--------------------------------------------------------------------------
  241. ; MODE SET ROUTINE
  242. ;  sets up a text or graphics mode as close as possible to the one
  243. ;  reguested by the user with regard to number of colors and size.
  244. ;
  245. ;  Entry: AX=mode selection
  246. ;     0 = 80x25 text
  247. ;     1 = default text
  248. ;     2 = text CX cols by DX rows
  249. ;     3 = biggest text
  250. ;     4 = 320x200 graphics
  251. ;     5 = default graphics
  252. ;     6 = graphics CX width by DX height
  253. ;     7 =